home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cutils.arc / KEY.ASM < prev    next >
Assembly Source File  |  1985-08-30  |  4KB  |  92 lines

  1.                         TITLE   Keyboard Subroutines for Lattice
  2.                         NAME    KEYBOARD
  3.                         INCLUDE DOS.MAC
  4.  
  5. COMMENT #
  6.                 AUTHOR          Jon Wesener
  7.                 DATE            7 / 16 / 85
  8.                 PURPOSE         These routines will give quick access
  9.                                 to the keyboard
  10.         #
  11.                 DSEG
  12. TABLESIZE       EQU     19
  13.  
  14. convert         db      75, 200         ; left character
  15.                 db      77, 201         ; right character
  16.                 db      82, 202         ; insert
  17.                 db      83, 203         ; delete
  18.                 db      59, 204         ; F1
  19.                 db      60, 205         ; F2
  20.                 db      61, 206         ; F3
  21.                 db      62, 207         ; F4
  22.                 db      63, 208         ; F5
  23.                 db      64, 209         ; F6
  24.                 db      65, 210         ; F7
  25.                 db      66, 211         ; F8
  26.                 db      67, 212         ; F9
  27.                 db      68, 213         ; F10
  28.                 db      71, 214         ; BOL
  29.                 db      79, 215         ; EOL
  30.                 db      73, 216         ; Page Up
  31.                 db      81, 217         ; Page Down
  32.                 db      115, 218        ; Previous Word
  33.                 db      116, 219        ; Next Word
  34.                 db       0, 0           ; invalid character, ignore
  35.                 ENDDS
  36.  
  37.                 PSEG
  38.                 PUBLIC  GETC, GETCW, GETCRAW
  39.  
  40. ; Getc returns a character if available and converts it via the table above.
  41. ;  ch= getc();
  42. ; RETURNS:      0= No character         ?= Character
  43.  
  44. GETC            PROC    NEAR
  45.                 push    bp
  46.                 mov     ax, 100h        ; get keyboard buffer status
  47.                 int     16h
  48.                 jz      nochar          ; no character available
  49. getc1:          xor     ax, ax
  50.                 int     16h             ; get character from buffer
  51.                 or      al, al          ; is is special ?
  52.                 jnz     not_spec        ; nope
  53.                 mov     bx, offset convert
  54.                 mov     cx, TABLESIZE
  55. gl1:            cmp     ah, [bx]        ; find it in table ?
  56.                 je      found           ; yes
  57.                 add     bx, 2           ; pt to next table entry
  58.                 loop    gl1             ; are we done with the table ?
  59. found:          inc     bx              ; pt to conversion character
  60.                 mov     al, [bx]        ; and get it
  61. not_spec:       xor     ah, ah          ; clean it up
  62. getex:          pop     bp
  63.                 ret                     ; and send it back !
  64. nochar:         xor     ax, ax          ; return nothing
  65.                 jmp     getex
  66. GETC            ENDP
  67.  
  68. ; Getcw waits for a key to be pressed and then converts it.
  69. ;  ch= getcw();
  70. ; RETURNS       converted character
  71.  
  72. GETCW           PROC    NEAR
  73.                 push    bp
  74.                 jmp     getc1
  75. GETCW           ENDP
  76.  
  77. ; Getcraw waits for a key to be pressed but doesn't convert it.
  78. ;  ch= getcraw()
  79. ; RETURNS:      al= 0   ah= special key
  80. ;               al= ?   ah= Scan code
  81.  
  82. GETCRAW         PROC    NEAR
  83.                 push    bp
  84.                 xor     ax, ax
  85.                 int     16h             ; wait for keyboard input
  86.                 pop     bp
  87.                 ret
  88. GETCRAW         ENDP
  89.                 ENDPS
  90.                 END
  91.  
  92.